//
//  SJRequest.m
//  WSL
//
//  Created by CJ on 2017/10/22.
//  Copyright © 2017年 sanjuetech. All rights reserved.
//

#import "SJRequest.h"

@implementation SJRequest {
    
    NSDictionary *_parameters;
}

- (id)initWithParameters:(NSDictionary *)parameters {
    
    self = [super init];
    if (self) {
        _parameters = parameters;
    }
    return self;
}

- (id)requestArgument {
    return _parameters;
}

- (NSTimeInterval)requestTimeoutInterval {
    return 15;
}

- (void)requestCompleteFilter {
    
    SJLog(@"******************  << success >>  ******************\n%@\n\n*****************************************************", self);
}

- (void)requestFailedFilter {
    
    SJLog(@"******************  << failure >>  ******************\n%@\n\n%@\n\n*****************************************************", self, self.error);
    
    [SVProgressHUD showErrorWithStatus:@"网络不给力"];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [SVProgressHUD dismiss];
    });
}

- (NSString *)description {
    
    return [NSString stringWithFormat:@"\n<%@: %p>\n{ URL: %@ }\n{ method: %@ }\n{ arguments: %@ }\n{ responseObject: %@ }", NSStringFromClass([self class]), self, self.currentRequest.URL, self.currentRequest.HTTPMethod, self.requestArgument, self.responseObject];
}

@end
